//+------------------------------------------------------------------+
//|        SF_MAP2.mq4                            by StraightFOREX      |
//|                                                                  |
//+------------------------------------------------------------------+

#property indicator_chart_window

   extern bool Daily   = True;
   extern bool Weekly  = False;

   double YesterdayHigh;
   double YesterdayLow;
   double YesterdayClose;
   double Yesterday2High;
   double Yesterday2Low;
   double Day_Price[][6];
   double Pivot,S1,S2,R1,R2;
   
   double WeekHigh;
   double WeekLow;
   double Week2High;
   double Week2Low;
   double WeekClose;
   double Weekly_Price[][6];
   double WeekPivot,WS1,WS2,WR1,WR2;
   
int init()
  {
   return(0);
  }
  
//-------------------------------------------------------- 
  
int deinit()
  {
ObjectDelete("PivotLine");

ObjectDelete("R1_Line");

ObjectDelete("R2_Line");

ObjectDelete("S1_Line");

ObjectDelete("S2_Line");

//--------------------------------

ObjectDelete("PivotLabel");

ObjectDelete("R1_Label");

ObjectDelete("R2_Label");

ObjectDelete("S1_Label");

ObjectDelete("S2_Label");

//--------------------------------------------------------

ObjectDelete("WeekPivotLine");

ObjectDelete("WR1_Line");

ObjectDelete("WR2_Line");

ObjectDelete("WS1_Line");

ObjectDelete("WS2_Line");

//--------------------------------

ObjectDelete("WeekPivotLabel");

ObjectDelete("WR1_Label");

ObjectDelete("WR2_Label");

ObjectDelete("WS1_Label");

ObjectDelete("WS2_Label");

return(0);
}
//--------------------------------------------------------- 

int start()
{

ArrayInitialize(Day_Price,0);
ArrayCopyRates(Day_Price,(Symbol()), 1440);

YesterdayHigh  = Day_Price[1][3];
YesterdayLow   = Day_Price[1][2];
YesterdayClose = Day_Price[1][4];
Yesterday2High  = Day_Price[2][3];
Yesterday2Low   = Day_Price[2][2];

Pivot = ((YesterdayHigh + YesterdayLow + YesterdayClose)/3);

   R1 = YesterdayLow;
   S1 = YesterdayHigh;
   R2 = Yesterday2Low;
   S2 = Yesterday2High;

//--------------------------------------------------------
//--------------------------------------------------------

ArrayInitialize(Weekly_Price, 0);
ArrayCopyRates(Weekly_Price, Symbol(), 10080);

WeekHigh  = Weekly_Price[1][3];
WeekLow   = Weekly_Price[1][2];
WeekClose = Weekly_Price[1][4];
Week2High  = Weekly_Price[2][3];
Week2Low   = Weekly_Price[2][2];

WeekPivot = ((WeekHigh + WeekLow + WeekClose)/3);

      WR1 = WeekLow;
      WS1 = WeekHigh;
      WR2 = Week2Low;
      WS2 = Week2High;

//--------------------------------------------------------

if (Daily==true)
{

ObjectCreate("PivotLine", OBJ_HLINE,0, CurTime(),Pivot);
ObjectSet("PivotLine", OBJPROP_COLOR, Red);
ObjectSet("PivotLine", OBJPROP_STYLE, STYLE_SOLID);

if(ObjectFind("PivotLabel") != 0)
{
ObjectCreate("PivotLabel", OBJ_TEXT, 0, Time[20], Pivot);
ObjectSetText("PivotLabel", "Pivot Point", 10, "Arial", Red);
}
else
{
ObjectMove("PivotLabel", 0, Time[20], Pivot);
}

//--------------------------------------------------------

ObjectCreate("R1_Line", OBJ_HLINE,0, CurTime(),R1);
ObjectSet("R1_Line", OBJPROP_COLOR, Blue);
ObjectSet("R1_Line", OBJPROP_STYLE, STYLE_DASHDOTDOT);

if(ObjectFind("R1_Label") != 0)
{
ObjectCreate("R1_Label", OBJ_TEXT, 0, Time[20], R1);
ObjectSetText("R1_Label", "LOPS1", 10, "Arial", Blue);
}
else
{
ObjectMove("R1_Label", 0, Time[20], R1);
}

//--------------------------------------------------------

ObjectCreate("R2_Line", OBJ_HLINE,0, CurTime(),R2);
ObjectSet("R2_Line", OBJPROP_COLOR, DarkOrange);
ObjectSet("R2_Line", OBJPROP_STYLE, STYLE_DASHDOTDOT);

if(ObjectFind("R2_Label") != 0)
{
ObjectCreate("R2_Label", OBJ_TEXT, 0, Time[20], R2);
ObjectSetText("R2_Label", "LOPS2", 10, "Arial", DarkOrange);
}
else
{
ObjectMove("R2_Label", 0, Time[20], R2);
}

//---------------------------------------------------------

ObjectCreate("S1_Line", OBJ_HLINE,0, CurTime(),S1);
ObjectSet("S1_Line", OBJPROP_COLOR, Blue);
ObjectSet("S1_Line", OBJPROP_STYLE, STYLE_DASHDOTDOT);

if(ObjectFind("S1_Label") != 0)
{
ObjectCreate("S1_Label", OBJ_TEXT, 0, Time[20], S1);
ObjectSetText("S1_Label", "HOPS1", 10, "Arial", Blue);
}
else
{
ObjectMove("S1_Label", 0, Time[20], S1);
}

//---------------------------------------------------------

ObjectCreate("S2_Line", OBJ_HLINE,0, CurTime(),S2);
ObjectSet("S2_Line", OBJPROP_COLOR, DarkOrange);
ObjectSet("S2_Line", OBJPROP_STYLE, STYLE_DASHDOTDOT);

if(ObjectFind("S2_Label") != 0)
{
ObjectCreate("S2_Label", OBJ_TEXT, 0, Time[20], S2);
ObjectSetText("S2_Label", "HOPS2", 10, "Arial", DarkOrange);
}
else
{
ObjectMove("S2_Label", 0, Time[20], S2);
}

}

ObjectsRedraw();

//---------------------------------------------------------
//---------------------------------------------------------
//---------------------------------------------------------

if (Weekly==true)
{
ObjectCreate("WeekPivotLine", OBJ_HLINE,0, CurTime(),WeekPivot);
ObjectSet("WeekPivotLine", OBJPROP_COLOR, Red);
ObjectSet("WeekPivotLine", OBJPROP_STYLE, STYLE_SOLID);

if(ObjectFind("WeekPivotLabel") != 0)
{
ObjectCreate("WeekPivotLabel", OBJ_TEXT, 0, Time[30], WeekPivot);
ObjectSetText("WeekPivotLabel", "Weekly Pivot Point", 10, "Arial", Red);
}
else
{
ObjectMove("WeekPivotLabel", 0, Time[30], WeekPivot);
}

//--------------------------------------------------------

ObjectCreate("WR1_Line", OBJ_HLINE,0, CurTime(),WR1);
ObjectSet("WR1_Line", OBJPROP_COLOR, Blue);
ObjectSet("WR1_Line", OBJPROP_STYLE, STYLE_DASHDOTDOT);

if(ObjectFind("WR1_Label") != 0)
{
ObjectCreate("WR1_Label", OBJ_TEXT, 0, Time[30], WR1);
ObjectSetText("WR1_Label", "W-LOPS1", 10, "Arial", Blue);
}
else
{
ObjectMove("WR1_Label", 0, Time[30], WR1);
}

//--------------------------------------------------------

ObjectCreate("WR2_Line", OBJ_HLINE,0, CurTime(),WR2);
ObjectSet("WR2_Line", OBJPROP_COLOR, DarkOrange);
ObjectSet("WR2_Line", OBJPROP_STYLE, STYLE_DASHDOTDOT);

if(ObjectFind("WR2_Label") != 0)
{
ObjectCreate("WR2_Label", OBJ_TEXT, 0, Time[30], WR2);
ObjectSetText("WR2_Label", "W-LOPS2", 10, "Arial", DarkOrange);
}
else
{
ObjectMove("WR2_Label", 0, Time[30], WR2);
}

//---------------------------------------------------------

ObjectCreate("WS1_Line", OBJ_HLINE,0, CurTime(),WS1);
ObjectSet("WS1_Line", OBJPROP_COLOR, Blue);
ObjectSet("WS1_Line", OBJPROP_STYLE, STYLE_DASHDOTDOT);

if(ObjectFind("WS1_Label") != 0)
{
ObjectCreate("WS1_Label", OBJ_TEXT, 0, Time[30], WS1);
ObjectSetText("WS1_Label", "W-HOPS1", 10, "Arial", Blue);
}
else
{
ObjectMove("WS1_Label", 0, Time[30], WS1);
}

//---------------------------------------------------------

ObjectCreate("WS2_Line", OBJ_HLINE,0, CurTime(),WS2);
ObjectSet("WS2_Line", OBJPROP_COLOR, DarkOrange);
ObjectSet("WS2_Line", OBJPROP_STYLE, STYLE_DASHDOTDOT);

if(ObjectFind("WS2_Label") != 0)
{
ObjectCreate("WS2_Label", OBJ_TEXT, 0, Time[30], WS2);
ObjectSetText("WS2_Label", "W-HOPS2", 10, "Arial", DarkOrange);
}
else
{
ObjectMove("WS2_Label", 0, Time[30], WS2);
}

}
//---------------------------------------------------------
//---------------------------------------------------------
//---------------------------------------------------------

ObjectsRedraw();

   return(0);
}